using System;
using System.Collections.Generic;
using System.Text;

namespace WineCellar.Web
{
    public class Message
    {
        public class Enums
        {
            public enum MessageClass { Information, Warning, Error };
        }
        private string _text;
        private Enums.MessageClass _messageClass;

        public Message(string text, Enums.MessageClass messageClass)
        {
            this._text = text;
            this._messageClass = messageClass;
        }
        public string Text
        {
            get { return this._text; }
            set { this._text = value; }

        }
        public Enums.MessageClass MessageClass
        {
            get { return this._messageClass; }
            set { this._messageClass = value; }
        }
    }
    public class MessageCollection : List<Message>
    {
        public MessageCollection GetMessagesInClass(Message.Enums.MessageClass messageClass)
        {
            List<Message> resultMessages = this.FindAll(
                new Predicate<Message>(
                delegate(Message message)
                {
                    return message.MessageClass == messageClass;
                }
                )
            );
            MessageCollection messages = new MessageCollection();
            messages.AddRange(resultMessages);
            return messages;
        }

    }
}
